﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Phone.Controls;

/**
 * 创建时间：2014/11/27 11:19:38
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.Common
{
    public class NaviService
    {
        private readonly static Uri StartPage;

        static NaviService()
        {
            NaviService.StartPage = new Uri("/IndexPage.xaml", UriKind.Relative);
        }



        public static bool Navigate(ComicIslandPage page, string param = "")
        {
            Uri navigateUri = NaviService.GetNavigateUri(page, param);
            if (!(Application.Current.RootVisual is PhoneApplicationFrame))
            {
                return false;
            }
            return ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(navigateUri);
        }

        private static Uri GetNavigateUri(ComicIslandPage page, string param = "")
        {
            Uri mainPage = null;
            switch (page)
            {
                case ComicIslandPage.StartPage: mainPage = NaviService.StartPage; break;
                case ComicIslandPage.PersonalCenterPage: mainPage = new Uri(string.Concat("/Views/PersonalCenterPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.SearchFilterPage: mainPage = new Uri(string.Concat("/Views/SearchFilterPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.BookStoreChannelMorePage: mainPage = new Uri(string.Concat("/Views/BookStoreChannelMorePage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDetailPage: mainPage = new Uri(string.Concat("/Views/ComicDetailPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.SearchBookAuthorPage: mainPage = new Uri(string.Concat("/Views/SearchBookAuthorPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicReaderPage: mainPage = new Uri(string.Concat("/Views/ComicReaderPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDetailChapterPage: mainPage = new Uri(string.Concat("/Views/ComicDetailChapterPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDetailChapterDownloadQueuePage: mainPage = new Uri(string.Concat("/Views/ComicDetailChapterDownloadQueuePage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDownloadChapterPage: mainPage = new Uri(string.Concat("/Views/ComicDownloadChapterPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDownloadPage: mainPage = new Uri(string.Concat("/Views/ComicDownloadPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.PersonalCenterAppConfigPage: mainPage = new Uri(string.Concat("/Views/PersonalCenterAppConfigPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.SpecialListPage: mainPage = new Uri(string.Concat("/Views/SpecialListPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CommunityPage: mainPage = new Uri(string.Concat("/Views/CommunityPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicDiscussionPage: mainPage = new Uri(string.Concat("/Views/ComicDiscussionPage.xaml", param), UriKind.Relative); break;

                #region 漫画社区
                case ComicIslandPage.CommunityDiscussionPage: mainPage = new Uri(string.Concat("/Views/CommunityDiscussionPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CommunityReviewPage: mainPage = new Uri(string.Concat("/Views/CommunityReviewPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CommunityDetailPage: mainPage = new Uri(string.Concat("/Views/CommunityDetailPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.ComicSummaryPage: mainPage = new Uri(string.Concat("/Views/ComicSummaryPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CommunityReviewUserPage: mainPage = new Uri(string.Concat("/Views/CommunityReviewUserPage.xaml", param), UriKind.Relative); break;    
                #endregion 漫画社区

                #region 缓存下载管理
                case ComicIslandPage.CDCacheManagePage: mainPage = new Uri(string.Concat("/Views/CacheDownload/ComicCacheManagePage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CDComicChapterCacheQueuePage: mainPage = new Uri(string.Concat("/Views/CacheDownload/ComicChapterCacheQueuePage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.CDComicChapterPage: mainPage = new Uri(string.Concat("/Views/CacheDownload/ComicChapterPage.xaml", param), UriKind.Relative); break;

                //case ComicIslandPage.DCVSelectedDownloadComicChapterPage: mainPage = new Uri(string.Concat("/Views/DownloadComicViews/SelectedDownloadComicChapterPage.xaml", param), UriKind.Relative); break;                
                //case ComicIslandPage.DCVDownloadComicList: mainPage = new Uri(string.Concat("/Views/DownloadComicViews/DownloadComicList.xaml", param), UriKind.Relative); break;
                //case ComicIslandPage.DCVDownloadQueuePage: mainPage = new Uri(string.Concat("/Views/DownloadComicViews/DownloadQueuePage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.DCVSelectedDownloadComicChapterPage: mainPage = new Uri(string.Concat("/Views/CacheManage/SelectComicChapterPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.DCVDownloadComicList: mainPage = new Uri(string.Concat("/Views/CacheManage/ComicPage.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.DCVDownloadQueuePage: mainPage = new Uri(string.Concat("/Views/CacheManage/QueuePage.xaml", param), UriKind.Relative); break;
                #endregion 缓存下载管理

                #region 阅读漫画
                //case ComicIslandPage.RCComicReaderPage: mainPage = new Uri(string.Concat("/Views/ReadComic/ComicReaderPage.xaml", param), UriKind.Relative); break;
                //case ComicIslandPage.RCComicReaderPage: mainPage = new Uri(string.Concat("/Views/ReadComic/ReadPagePanorama.xaml", param), UriKind.Relative); break;
                //case ComicIslandPage.RCComicReaderPage: mainPage = new Uri(string.Concat("/Views/ReadComic/ImageViewPage.xaml", param), UriKind.Relative); break;
                //case ComicIslandPage.RCComicReaderPage: mainPage = new Uri(string.Concat("/Views/ReadComicImage/ReadPagePanorama.xaml", param), UriKind.Relative); break;
                case ComicIslandPage.RCComicReaderPage: mainPage = new Uri(string.Concat("/Views/ReadComicImage/ComicReadPage.xaml", param), UriKind.Relative); break; 
                #endregion 阅读漫画

                #region 其它页面
                case ComicIslandPage.OtherComicFeedbackPage: mainPage = new Uri(string.Concat("/Views/ComicFeedbackPage.xaml", param), UriKind.Relative); break;
                #endregion 其它页面
            }
            return mainPage;
        }
    }

    public enum ComicIslandPage
    {
        StartPage,
        /// <summary>
        /// 点击查看更多漫画（书城）
        /// </summary>
        BookStoreChannelMorePage,
        /// <summary>
        /// 漫画详情页
        /// </summary>
        ComicDetailPage,
        PersonalCenterPage,
        /// <summary>
        /// 根据作者搜索书籍
        /// </summary>
        SearchBookAuthorPage,
        /// <summary>
        /// 阅读页
        /// </summary>
        ComicReaderPage,

        SearchFilterPage,

        #region 漫画阅读
        ComicSummaryPage,
        /// <summary>
        /// 点击进入主题评论列表
        /// </summary>
        ComicDiscussionPage,
        /// <summary>
        /// 章节页
        /// </summary>
        ComicDetailChapterPage,
        /// <summary>
        /// 章节下载队列
        /// </summary>
        ComicDetailChapterDownloadQueuePage,
        /// <summary>
        /// 下载漫画列表
        /// </summary>
        ComicDownloadPage,
        /// <summary>
        /// 下载漫画对应的章节列表
        /// </summary>
        ComicDownloadChapterPage,

        /// <summary>
        /// 漫画阅读
        /// </summary>
        RCComicReaderPage,
        #endregion 漫画阅读

        #region 漫画缓存
        /// <summary>
        /// 某漫画的目录列表
        /// </summary>
        CDComicChapterPage,
        /// <summary>
        /// 缓存漫画列表
        /// </summary>
        CDCacheManagePage,
        /// <summary>
        /// 某漫画章节缓存列表
        /// </summary>
        CDComicChapterCacheQueuePage,

        DCVSelectedDownloadComicChapterPage,
        DCVDownloadComicList,
        DCVDownloadQueuePage,
        #endregion 漫画缓存

        #region 个人中心
        /// <summary>
        /// 软件设置
        /// </summary>
        PersonalCenterAppConfigPage,
        /// <summary>
        /// 专题列表页
        /// <para></para>
        /// </summary>
        SpecialListPage,
        #endregion 个人中心

        #region 漫画社区
        CommunityPage,
        CommunityDiscussionPage,
        CommunityReviewPage,
        CommunityDetailPage,
        CommunityReviewUserPage,
        #endregion 漫画社区

        /// <summary>
        /// 反馈意见
        /// </summary>
        OtherComicFeedbackPage,
    }
}
